using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace DD.Admin.Controls
{
    public partial class ManageCategories : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (DetailsView1.Rows.Count == 0)
            {
                DetailsView1.DefaultMode = DetailsViewMode.Insert;
            }
            //DetailsView1.ItemDeleting += new DetailsViewDeleteEventHandler(DetailsView1_ItemDeleting);
            GridView1.RowDeleting += new GridViewDeleteEventHandler(GridView1_RowDeleting);
        }

        void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int Rid = (int)GridView1.DataKeys[e.RowIndex].Value;
            if (DD.Category.CategoryManager.CategoryAssigned(Rid))
            {
                e.Cancel = true;
                this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CantCancel", "show_alert('This Category cannot be deleted because it is assigned to a product')", true);

            }
        }

        


        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        
                
        



    }
}